// main.cpp
#include "test_string.h"
#include <gtest/gtest.h>

// 测试 C-style 风格字符串
TEST(StringTests, StringEquality)
{
    // C-style string comparisons
    char dst[128] = { 0 };
    char src1[] = "hello";
    char src2[] = " world";
    ASSERT_STREQ("hello world", add_str(dst, src1, src2)); // --PASS
    // ASSERT_STREQ("hello, world", add_str(dst, src1, src2));     // --FAILED
}

// 测试 C++ 风格字符串
TEST(StringFunctionsTest, ToUpper) {
    EXPECT_EQ(to_upper("hello"), "HELLO");
    EXPECT_EQ(to_upper("World"), "WORLD");
    EXPECT_EQ(to_upper("123"), "123");
    EXPECT_EQ(to_upper("!@#"), "!@#");
    EXPECT_EQ(to_upper(""), "");
}

TEST(AddStringTest, add_string) {
    string s1 = "123";
    string s2 = "456";
    EXPECT_EQ(add_string(s1,s2), "123456");

    s1 = "abc";
    s2 = "def";
    EXPECT_EQ(add_string(s1,s2), "abcdef");
}

int main(int argc, char** argv)
{
    testing::InitGoogleTest(&argc, argv);
    /* 用TEST宏定义测试用例，验证函数的行为和结果是否符合预期 */

    return RUN_ALL_TESTS();
}
